package sg.nus.iss.vmcs.controllers;

import sg.nus.iss.vmcs.gui.GUIChangeManager;
import sg.nus.iss.vmcs.gui.GUIChangeManagerEvent;

/**
 * Dispense Controller for the drinks dispenser
 * @author Philip Chew
 */
public class DispenseController {

	/** Transaction Controller */
	private TransactionController transCtrl;
	
	/**
	 * Creates an instance of the dispense controller
	 * @param transCtrl Reference to the transaction controller
	 */
	public DispenseController(TransactionController transCtrl) {
		this.transCtrl = transCtrl;
	}
	
	/**
	 * Instructs the Can Collection Box to remove
	 */
	public void resetCan() {
		GUIChangeManager.getInstance().fireEvent(GUIChangeManagerEvent.SetCan);
	}
	
	/**
	 * Used to activate or deactivate the drinks selection box
	 * @param True to allow, false for otherwise
	 */
	public void allowSelection(boolean allow) {
		GUIChangeManager.getInstance().fireEvent(GUIChangeManagerEvent.AllowCanSelection, allow);
	}
	
	/**
	 * Dispenses a drink
	 * @param selectedBrand The drinks brand that is selected
	 */
	public boolean dispenseDrink(int selectedBrand) {
		return this.transCtrl.getMainController().getMachineryController().dispenseDrink(selectedBrand);
	}
	
	/**
	 * Displays the latest stock and price information in the drink selection box
	 * @param index
	 */
	public void updateDrinkSelection(int index) {
		
	}
	
	/**
	 * Updates the whole drink selection box with current names, stock and prices
	 */
	public void updateDrinkPanel() {
		
	}
}
